import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import Element, {Message} from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import axios from 'axios'
import './assets/@fortawesome/fontawesome-free/css/all.min.css'
import './assets/font-awesome-4.7.0/css/font-awesome.min.css'
import qs from 'qs'
import jq from 'jquery/dist/jquery'
import echarts from 'echarts'


Vue.config.productionTip = false
Vue.use(Element);
Vue.prototype.$axios=axios;
Vue.prototype.qs=qs;
Vue.prototype.$echarts = echarts;
Vue.use(echarts);

axios.defaults.baseURL='/api';
// axios.defaults.headers.post['Content-type']='application/json;charset=UTF-8';

// 访问后端时带验证码，后端验证登录状态
// 开发暂时不使用
axios.interceptors.request.use(
  config =>{
    if (localStorage.getItem('Authorization')){
      config.headers.token=localStorage.getItem('Authorization')
    }
    return config;
  },error => {
      return Promise.reject(error);
    }
);
  axios.interceptors.response.use(res=>{
      return res
  },error => {
    if (error.response.status == 403){
      Message.error('登录已经失效,返回登录页面');
      router.push('/');
    }

  } );


new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
